package com.crm.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.crm.dao.CustomerDao;
import com.crm.dao.LinkmanDao;
import com.crm.dao.SaleVisitDao;
import com.crm.dao.impl.CustomerDaoImpl;
import com.crm.dao.impl.LinkmanDaoImpl;
import com.crm.dao.impl.SaleVisitDaoImpl;
import com.crm.pojo.PageInfo;
import com.crm.pojo.SaleVisit;
import com.crm.service.SaleVisitService;

public class SaleVisitServiceImpl implements SaleVisitService {
	CustomerDao customerDao = new CustomerDaoImpl();
	LinkmanDao linkmanDao = new LinkmanDaoImpl();
	SaleVisitDao visitDao = new SaleVisitDaoImpl();
	@Override
	public List<Map> queryCustomer() {
		return customerDao.queryCustomer();
	}
	@Override
	public List<Map> queryLkm(Integer custId) {
		return linkmanDao.queryLkm(custId);
	}
	@Override
	public boolean insertVisit(SaleVisit visit) {
		boolean flag = false;
		int n = visitDao.insertVisit(visit);
		if(n==1) {
			flag = true;
		}
		return flag;
	}
	@Override
	public PageInfo queryVisit(String custName, Integer pageSize, Integer pageNumber) {
		return visitDao.queryVisit(custName,pageSize,pageNumber);
	}
	@Override
	public boolean delete(Integer visitId) {
		boolean flag = false;
		int n = visitDao.delete(visitId);
		if(n==1) {
			flag = true;
		}
		return flag;
	}
	@Override
	public Map queryVisitById(Integer visitId) {
		List<Map> visits = visitDao.queryVisitById(visitId);
		Map visit = new HashMap();
		for(Map v:visits) {
			visit = v;
		}
		return visit;
	}
	@Override
	public boolean updateVisit(SaleVisit visit) {
		boolean flag = false;
		int n = visitDao.updateVisit(visit);
		if(n==1) {
			flag = true;
		}
		return flag;
	}


}
